package com.force.common.h2.config;

import com.force.common.h2.models.H2JdbcTemplate;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;


@Configuration
public class H2Config {

	@Bean
	public DataSource h2DataSource() {
		return DataSourceBuilder.create()
				.driverClassName("org.h2.Driver")
				.url("jdbc:h2:file:./h2/testdb.db")
				.username("sa")
				.password("123123")
				.build();
	}
	@Bean
	public H2JdbcTemplate h2JdbcTemplate(){
		H2JdbcTemplate h2JdbcTemplate = new H2JdbcTemplate(h2DataSource());
		return h2JdbcTemplate;
	}



}
